window.onload = function () {
    const user = document.querySelector('.user');
   const aviheight=getComputedStyle(user,null).height;


    const back = document.querySelector('.back');
    const shadow = document.querySelector('.content2');
    const main_block = document.querySelectorAll('.main-block');
    var nav = document.querySelectorAll('.dao>ul>li>a');
    var index, cur = 0;
    function bodyScroll(event){
        event.preventDefault();
    }
    for (let i = 0; i < main_block.length; i++) {
        main_block[i].style.display = 'none';
    }
    for (let i = 0; i < nav.length; i++) {
        nav[i].num = i;

        main_block[i].num = i;
        const current = document.querySelector('.current');
        cur = current.num;
        main_block[cur].style.display = 'block';
        nav[i].addEventListener('click', function () {

            for (let j = 0; j < nav.length; j++) {
                nav[j].classList.remove('current');
                main_block[j].style.display = 'none';
            }
            index = this.num;
            main_block[index].style.display = 'block';
            nav[index].classList.add('current');

        });

    }




    const menu = document.querySelector('.menu');
    menu.addEventListener('click', function (e) {
        shadow.style.display = 'block';
        shadow.style.height=aviheight;


        user.style.cssText = "animation: moveuser .6s linear forwards;"
        // e.preventDefault();
        // user.style.height=document.body.clientHeight+'px';
        shadow.addEventListener('touchmove',bodyScroll,false);
        user.addEventListener('touchmove',bodyScroll,false);

    });
    back.addEventListener('click', function (e) {
        shadow.removeEventListener('touchmove',bodyScroll,false);
        user.removeEventListener('touchmove',bodyScroll,false);
        // user.style.height=document.body.clientHeight+'px';

        shadow.style.display = 'none';
        user.style.cssText = "animation: leaveuser .6s linear forwards;"


    });

    const search = document.querySelector('nav>.search');
    search.addEventListener('click', function () {
        self.location = 'search.html';
    })
}